﻿using EntityModel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Security.Cryptography.X509Certificates;

namespace API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class BulidController : ControllerBase
    {
        private readonly DZJDBcontext db;

        public BulidController(DZJDBcontext context)
        {
            db = context;
        }
        [HttpGet]
        public List<EM_Bulid> Get()
        {

            return db.EM_Bulid.ToList();
        }
        //[HttpGet("{id}")]
        //public EM_Bulid? GetEM_BulidById(Guid Id)
        //{
        //    EM_Bulid? bulid = new EM_Bulid();
        //    bulid = db.EM_Bulid.Where(s => s.Id == Id).FirstOrDefault();
        //    return bulid;
        //}
        //[HttpGet("like/{name}")]
        //public List<EM_Bulid> GetEM_BulidLikeName(string name)
        //{
        //    List<EM_Bulid> bulids = new List<EM_Bulid>();
        //    bulids = db.EM_Bulid.Where(s => s.Type.Contains(name)).ToList();
        //    return bulids;
        //}
        [HttpPost]
        public bool Add(EM_Bulid bulid)
        {
            db.EM_Bulid.Add(bulid);
            int result = db.SaveChanges();
            return result > 0 ? true : false;
        }
        [HttpPut]
        public bool Update(EM_Bulid bulid)
        {
            db.EM_Bulid.Update(bulid);
            int result = db.SaveChanges();
            return result > 0 ? true : false;
        }
        [HttpDelete]
        public bool Delete(EM_Bulid bulid)
        {
            db.EM_Bulid.Update(bulid);
            int result = db.SaveChanges();
            return result > 0 ? true : false;
        }
    }
}
                   